package com.huawei.appgallery.foundation.ui.framework.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;
import huawei.widget.HwTextView;
import java.lang.ref.WeakReference;
import o.cix;
import o.dky.h;
import o.dky.i;
import o.dky.j;

public class FooterView extends LinearLayout {
    private int ʻ;
    private int ʼ;
    private int ʽ = 0;
    private TextView ˊ = null;
    private View ˋ = null;
    private HwTextView ˋॱ;
    public boolean ˎ = false;
    private View ˏ = null;
    private cix ͺ;
    private View ॱ = null;
    private int ॱॱ;
    private View ᐝ = null;

    static class c implements Runnable {
        private WeakReference<FooterView> ˊ;

        public c(FooterView footerView) {
            this.ˊ = new WeakReference(footerView);
        }

        public void run() {
            FooterView footerView = (FooterView) this.ˊ.get();
            if (footerView != null) {
                footerView.requestLayout();
            }
        }
    }

    public FooterView(Context context) {
        super(context);
        ˋ(context);
    }

    public FooterView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        ˋ(context);
    }

    private void ˋ(Context context) {
        LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
        layoutParams.gravity = 16;
        this.ˏ = LayoutInflater.from(context).inflate(i.ॱ, null);
        this.ॱ = this.ˏ.findViewById(h.ʹ);
        this.ˊ = (TextView) this.ˏ.findViewById(h.ˋʼ);
        this.ᐝ = this.ˏ.findViewById(h.ʼ);
        this.ˋ = this.ˏ.findViewById(h.ﹳ);
        this.ˋॱ = (HwTextView) this.ˏ.findViewById(h.ㆍ);
        this.ॱॱ = context.getResources().getDimensionPixelSize(o.dky.c.ʿ);
        this.ʻ = context.getResources().getDimensionPixelSize(o.dky.c.ॱˎ);
        this.ʼ = context.getResources().getDimensionPixelSize(o.dky.c.ॱˋ);
        addView(this.ˏ, layoutParams);
    }

    public void setFooterViewHeight(int i) {
        this.ʻ = i;
    }

    public void setFootViewListener(cix o_cix) {
        this.ͺ = o_cix;
    }

    public void ˏ() {
        ˏ(0);
    }

    public void ˏ(int i) {
        if (this.ʽ != i) {
            this.ˊ.setText(getResources().getString(j.ʼᐝ));
            this.ˊ.setClickable(false);
            ˊ(this.ˋ, 0);
            this.ˎ = false;
            this.ʽ = i;
        }
    }

    public int ˊ() {
        return this.ʽ;
    }

    public void setFooterHeight(int i) {
        if (i <= 0) {
            i = 0;
        }
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.ˏ.getLayoutParams();
        if (layoutParams.height != i) {
            layoutParams.height = i;
            this.ˏ.setLayoutParams(layoutParams);
            postDelayed(new c(this), 10);
        }
    }

    public void ˊ(String str, OnClickListener onClickListener) {
        if (this.ˏ != null) {
            this.ˎ = true;
            this.ˊ.setText(str);
            this.ˊ.setClickable(true);
            ˊ(this.ˋ, 8);
            this.ʽ = 0;
            if (onClickListener != null) {
                this.ˊ.setOnClickListener(onClickListener);
            }
        }
    }

    public void ˋ() {
        ˊ(this.ᐝ, 8);
        ˊ(this.ॱ, 8);
        setFooterHeight(this.ॱॱ);
        this.ʽ = 3;
        if (this.ͺ != null) {
            this.ͺ.ॱـ();
        }
    }

    public void ॱ() {
        ˊ(this.ᐝ, 8);
        if (this.ॱ != null) {
            if (this.ॱ.getVisibility() == 4) {
                ˊ(this.ॱ, 0);
            } else if (this.ॱ.getVisibility() == 8) {
                ˊ(this.ॱ, 0);
                setFooterHeight(this.ʻ);
            }
        }
        if (this.ʽ == 3) {
            this.ʽ = 0;
        }
        if (this.ͺ != null) {
            this.ͺ.ॱʾ();
        }
    }

    public void ˎ() {
        int i = this.ʼ;
        if (this.ॱ.getVisibility() == 0) {
            i += this.ʻ;
        }
        setFooterHeight(i);
        this.ᐝ.setVisibility(0);
    }

    public void ᐝ() {
        int i = this.ॱॱ;
        if (this.ॱ.getVisibility() == 0) {
            i += this.ʻ;
        }
        setFooterHeight(i);
        this.ᐝ.setVisibility(8);
    }

    private void ˊ(View view, int i) {
        if (view != null && view.getVisibility() != i) {
            view.setVisibility(i);
        }
    }

    public View ʼ() {
        return this.ॱ;
    }

    public void setmLoadingLayout(View view) {
        this.ॱ = view;
    }

    public void setBlankHeight(int i) {
        this.ʼ = i;
    }

    public void ˊ(int i) {
        if (i == 0) {
            LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.ˏ.getLayoutParams();
            if (layoutParams != null) {
                layoutParams.height = -2;
                this.ˏ.setLayoutParams(layoutParams);
            }
        }
        this.ˋॱ.setVisibility(i);
    }
}
